package com.itheima.HomeWork.homework05;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Text {
    public static void main(String[] args) throws IOException {
        List<Student> stuList = new ArrayList<>();
        stuList.add(new Student("张三", "男", "20", "88"));
        stuList.add(new Student("李四", "女", "19", "99"));
        FileOutputStream fos = new FileOutputStream("E:\\img1\\student.txt");
        /*for (Student student : stuList) {
            fos.write((student.getName() + "," + student.getSex() + "," + student.getAge() + "," + student.getScore() + "\n").getBytes());
        }*/

        /*stuList.forEach(student -> {
            try {
                fos.write(student.toString().getBytes());
                fos.write(System.lineSeparator().getBytes());

            } catch (IOException e) {
               e.printStackTrace();
            }
        });
        fos.close();*/
        for (Student student : stuList) {
            fos.write(student.toString().getBytes());
            fos.write(System.lineSeparator().getBytes());
        }
        fos.close();
    }
}
